<?php
$banhao = $_REQUEST["banhao"];
$banzhang = $_REQUEST["banzhang"];
$jiaoshi = $_REQUEST["jiaoshi"];
$banzhuren = $_REQUEST["banzhuren"];
$kouhao = $_REQUEST["kouhao"];
$action = $_REQUEST["action"];
echo "$banhao";
echo "$banzhang";
echo "$jiaoshi";
echo "$banzhuren";
echo "$kouhao";

include_once("conn.php");
//3.运行sql语句，执行增、删、改、查
if($action=="add"){
    $sql1 = "insert into `班级`(班号,班长,教室,班主任,班级口号)value('{$banhao}','{$banzhang}','{$jiaoshi}','{$banzhuren}','{$kouhao}')";
    header("Refresh:1;url=banji-input.php");
    $str = "数据插入成功";
}else if($action=="update"){
    $sql1 = "update 班级 set 班号='{$banhao}',班长='{$banzhang}',教室='{$jiaoshi}',班主任='{$banzhuren}',班级口号='{$kouhao}' where 班号='{$banhao}'";
    header("Refresh:1;url=banji-list.php");
    $str = "数据修改成功";
}else{
    die("请正确输入参数");
}
// $sql1 = "insert into `班级`(班号,班长,教室,班主任,班级口号)value('{$banhao}','{$banzhang}','{$jiaoshi}','{$banzhuren}','{$kouhao}')";
$result = mysqli_query($conn,$sql1);
if($result){
    echo "<script>alert('$str')</script>";
    // header("Refresh:1;url=banji-input.php");
}else{
    echo "<script>alert('数据插入失败')</script>";
}
//4.关闭连接，释放资源
mysqli_close($conn);

?>